package pl.nazaweb.imedproplus.model.entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "organization_structure")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrganizationStructure.findAll", query = "SELECT o FROM OrganizationStructure o"),
    @NamedQuery(name = "OrganizationStructure.findByIdAndParentIsNull", query = "SELECT o FROM OrganizationStructure o WHERE o.id = :id AND o.parent is null"),
    @NamedQuery(name = "OrganizationStructure.findById", query = "SELECT o FROM OrganizationStructure o WHERE o.id = :id"),
    @NamedQuery(name = "OrganizationStructure.findByCode", query = "SELECT o FROM OrganizationStructure o WHERE o.code = :code"),
    @NamedQuery(name = "OrganizationStructure.findByType", query = "SELECT o FROM OrganizationStructure o WHERE o.type = :type"),
    @NamedQuery(name = "OrganizationStructure.findByName", query = "SELECT o FROM OrganizationStructure o WHERE o.name = :name"),
    @NamedQuery(name = "OrganizationStructure.findByNfzCode", query = "SELECT o FROM OrganizationStructure o WHERE o.nfzCode = :nfzCode"),
    @NamedQuery(name = "OrganizationStructure.findByStatus", query = "SELECT o FROM OrganizationStructure o WHERE o.status = :status"),
    @NamedQuery(name = "OrganizationStructure.findByDepartmentCodePart3", query = "SELECT o FROM OrganizationStructure o WHERE o.departmentCodePart3 = :departmentCodePart3"),
    @NamedQuery(name = "OrganizationStructure.findByDepartmentCodePart6", query = "SELECT o FROM OrganizationStructure o WHERE o.departmentCodePart6 = :departmentCodePart6"),
    @NamedQuery(name = "OrganizationStructure.findByDepartmentCodePart5", query = "SELECT o FROM OrganizationStructure o WHERE o.departmentCodePart5 = :departmentCodePart5"),
    @NamedQuery(name = "OrganizationStructure.findByDepartmentCodePart7", query = "SELECT o FROM OrganizationStructure o WHERE o.departmentCodePart7 = :departmentCodePart7"),
    @NamedQuery(name = "OrganizationStructure.findByDepartmentCodePart8", query = "SELECT o FROM OrganizationStructure o WHERE o.departmentCodePart8 = :departmentCodePart8"),
    @NamedQuery(name = "OrganizationStructure.findByParent", query = "SELECT o FROM OrganizationStructure o WHERE o.parent = :parent"),
    @NamedQuery(name = "OrganizationStructure.findByHasChild", query = "SELECT o FROM OrganizationStructure o WHERE o.hasChild = :hasChild")})
public class OrganizationStructure implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name = "organization_structure_sequence_", sequenceName = "organization_structure_sequence", allocationSize=1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "organization_structure_sequence_")
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Long id;
    @Size(max = 10)
    @Column(name = "code")
    private String code;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "type")
    private String type;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 250)
    @Column(name = "name")
    private String name;
    @Size(max = 15)
    @Column(name = "nfz_code")
    private String nfzCode;
    @Basic(optional = false)
    @NotNull
    @Column(name = "status")
    private int status;
    @Size(max = 20)
    @Column(name = "department_code_part_3")
    private String departmentCodePart3;
    @Size(max = 20)
    @Column(name = "department_code_part_6")
    private String departmentCodePart6;
    @Size(max = 20)
    @Column(name = "department_code_part_5")
    private String departmentCodePart5;
    @Size(max = 20)
    @Column(name = "department_code_part_7")
    private String departmentCodePart7;
    @Size(max = 20)
    @Column(name = "department_code_part_8")
    private String departmentCodePart8;
    @Column(name = "parent")
    private BigInteger parent;
    @Basic(optional = false)
    @NotNull
    @Column(name = "has_child")
    private boolean hasChild;

    public OrganizationStructure() {
    }

    public OrganizationStructure(Long id) {
        this.id = id;
    }

    public OrganizationStructure(Long id, String type, String name, int status, boolean hasChild) {
        this.id = id;
        this.type = type;
        this.name = name;
        this.status = status;
        this.hasChild = hasChild;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNfzCode() {
        return nfzCode;
    }

    public void setNfzCode(String nfzCode) {
        this.nfzCode = nfzCode;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getDepartmentCodePart3() {
        return departmentCodePart3;
    }

    public void setDepartmentCodePart3(String departmentCodePart3) {
        this.departmentCodePart3 = departmentCodePart3;
    }

    public String getDepartmentCodePart6() {
        return departmentCodePart6;
    }

    public void setDepartmentCodePart6(String departmentCodePart6) {
        this.departmentCodePart6 = departmentCodePart6;
    }

    public String getDepartmentCodePart5() {
        return departmentCodePart5;
    }

    public void setDepartmentCodePart5(String departmentCodePart5) {
        this.departmentCodePart5 = departmentCodePart5;
    }

    public String getDepartmentCodePart7() {
        return departmentCodePart7;
    }

    public void setDepartmentCodePart7(String departmentCodePart7) {
        this.departmentCodePart7 = departmentCodePart7;
    }

    public String getDepartmentCodePart8() {
        return departmentCodePart8;
    }

    public void setDepartmentCodePart8(String departmentCodePart8) {
        this.departmentCodePart8 = departmentCodePart8;
    }

    public BigInteger getParent() {
        return parent;
    }

    public void setParent(BigInteger parent) {
        this.parent = parent;
    }

    public boolean getHasChild() {
        return hasChild;
    }

    public void setHasChild(boolean hasChild) {
        this.hasChild = hasChild;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrganizationStructure)) {
            return false;
        }
        OrganizationStructure other = (OrganizationStructure) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.nazaweb.imedproplus.model.entity.OrganizationStructure[ id=" + id + " ]";
    }

}
